package com.easyxu.kubernetes.filebrowser.service.executor;

import com.easyxu.kubernetes.filebrowser.service.dto.FileDownloadCmd;
import io.kubernetes.client.Copy;
import io.kubernetes.client.openapi.ApiException;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.io.InputStream;

@Component
public class FileDownloadCmdExe {

    public InputStream execute(FileDownloadCmd cmd) throws IOException, ApiException {
        Copy copy = new Copy();
        InputStream dataStream = copy.copyFileFromPod(cmd.getNamespace(), cmd.getPod(), cmd.getFilePath());
        return dataStream;
    }
}
